package com.ruoyi.module.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.module.mapper.UserEvalRecordMapper;
import com.ruoyi.module.domain.UserEvalRecord;
import com.ruoyi.module.service.IUserEvalRecordService;
import com.ruoyi.common.utils.SecurityUtils;

/**
 * 用户评测记录Service业务层处理
 * 
 * @author ruoyi
 */
@Service
public class UserEvalRecordServiceImpl implements IUserEvalRecordService 
{
    @Autowired
    private UserEvalRecordMapper userEvalRecordMapper;

    /**
     * 查询用户评测记录
     */
    @Override
    public UserEvalRecord selectUserEvalRecordById(Long id)
    {
        return userEvalRecordMapper.selectUserEvalRecordById(id);
    }

    /**
     * 查询用户评测记录列表
     */
    @Override
    public List<UserEvalRecord> selectUserEvalRecordList(UserEvalRecord userEvalRecord)
    {
        if (userEvalRecord.getUserId() == null) {
            userEvalRecord.setUserId(SecurityUtils.getUserId());
        }
        return userEvalRecordMapper.selectUserEvalRecordList(userEvalRecord);
    }

    /**
     * 新增用户评测记录
     */
    @Override
    public int insertUserEvalRecord(UserEvalRecord userEvalRecord)
    {
        if (userEvalRecord.getUserId() == null) {
            userEvalRecord.setUserId(SecurityUtils.getUserId());
        }
        return userEvalRecordMapper.insertUserEvalRecord(userEvalRecord);
    }

    /**
     * 批量新增用户评测记录
     */
    @Override
    public int batchInsertUserEvalRecord(List<UserEvalRecord> userEvalRecordList)
    {
        Long userId = SecurityUtils.getUserId();
        for (UserEvalRecord record : userEvalRecordList) {
            if (record.getUserId() == null) {
                record.setUserId(userId);
            }
        }
        return userEvalRecordMapper.batchInsertUserEvalRecord(userEvalRecordList);
    }

    /**
     * 修改用户评测记录
     */
    @Override
    public int updateUserEvalRecord(UserEvalRecord userEvalRecord)
    {
        return userEvalRecordMapper.updateUserEvalRecord(userEvalRecord);
    }

    /**
     * 批量删除用户评测记录
     */
    @Override
    public int deleteUserEvalRecordByIds(Long[] ids)
    {
        return userEvalRecordMapper.deleteUserEvalRecordByIds(ids);
    }

    /**
     * 删除用户评测记录信息
     */
    @Override
    public int deleteUserEvalRecordById(Long id)
    {
        return userEvalRecordMapper.deleteUserEvalRecordById(id);
    }

    /**
     * 根据UUID查询评测记录
     */
    @Override
    public List<UserEvalRecord> selectUserEvalRecordByUuid(String uuid)
    {
        return userEvalRecordMapper.selectUserEvalRecordByUuid(uuid);
    }
}

